
package com.scs.application.modules.base.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.scs.application.core.service.BaseServiceImpl;
import com.scs.application.core.utils.StringUtils;
import com.scs.application.modules.base.entity.ApplicantCertificateRecord;
import com.scs.application.modules.base.mapper.ApplicantCertificateRecordMapper;
import com.scs.application.modules.base.request.ApplicantCertificateRecordQueryRequest;
import com.scs.application.modules.base.service.ApplicantCertificateRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 资格申请资质记录 service 实现
 */
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class ApplicantCertificateRecordServiceImpl extends BaseServiceImpl<ApplicantCertificateRecordMapper, ApplicantCertificateRecord> implements ApplicantCertificateRecordService {

    @Override
    public List<ApplicantCertificateRecord> list(ApplicantCertificateRecordQueryRequest request) {
        List<ApplicantCertificateRecord> list = this.baseMapper.list(request);
        return list;
    }

    @Override
    public IPage<ApplicantCertificateRecord> page(ApplicantCertificateRecordQueryRequest request) {
        IPage page = this.page(request.getPage(), getQueryWrapper(request));
        return page;
    }

    private QueryWrapper<ApplicantCertificateRecord> getQueryWrapper(ApplicantCertificateRecordQueryRequest request) {
        return Wrappers.<ApplicantCertificateRecord>query()
                .like(StringUtils.isNotBlank(request.getSupplierName()), "supplier_name", request.getSupplierName())
                .orderByDesc("gmt_modified");
    }
}
